package com.xnyzc.lhy.mis.mapper.order;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xnyzc.lhy.mis.entity.order.OaCOrderPersonal;
import com.xnyzc.lhy.mis.entity.order.OaDOrder;
import com.xnyzc.lhy.mis.entity.result.cms.driver.CmsDriverSettlementDataListRes;
import com.xnyzc.lhy.mis.entity.result.cms.driver.CmsDriverSettlementDataResult;
import com.xnyzc.lhy.mis.entity.result.cms.driver.CmsDriversettlementExportList;
import com.xnyzc.lhy.mis.entity.result.order.DriverOrderCard;
import com.xnyzc.lhy.mis.entity.result.order.OrderList;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 司机接单表 Mapper 接口
 * </p>
 *
 * @author lhy@xnyzc.com
 * @since 2019-07-31
 */
public interface OaDOrderMapper extends BaseMapper<OaDOrder> {


    /**
     * @param iPage：分页器
     * @param orderNo：订单编号
     * @param orderStatus：订单状态
     * @param userName：乘客姓名
     * @param userPhone：乘客手机号
     * @param cityId：城市Code
     * @param isChangePrice：是否改价
     * @param startAddress：出发地地址
     * @param endAddress：目的地地址
     * @param isRefund：是否退款
     * @param vehicleType：业务类型
     * @param cancelReason：取消原因
     * @param orderTime：下单时间
     * @param arriveTime：到达时间
     * @param orderType：订单类型
     * @param didiOrderId：流量方订单编号
     * @param orderChannel：订单取消
     * @param dUsedId：司机ID
     * @param vehicleId：车辆ID
     * @return
     */
    @Select(
            "<script>" +
                    "SELECT  " +
                    "oa_c_order_personal.personal_id," +
                    "oa_c_order_personal.order_no," +
                    "oa_c_order_personal.city_id," +
                    "oa_c_order_personal.vehicle_type," +
                    "odc.dayCount,"+
                    "oa_c_order_personal.order_type," +
                    "oa_c_order_personal.order_status," +
                    "oa_c_order_personal.passenger_name as user_name," +
                    "oa_c_order_personal.passenger_phone as user_phone," +
                    "oa_c_order_personal.expand2," +
                    "oa_c_order_personal.didi_order_id," +
                    "oa_c_order_personal.order_channel," +
                    "oa_c_order_personal.driver_id," +
                    "oa_c_order_personal.vehicle_id," +
                    "oa_c_order_personal.vehicle_id," +
                    "oa_c_order_personal.office_id," +
                    "oa_c_order_personal.appointment," +
                    "oa_c_order_personal.start_address," +
                    "oa_c_order_personal.end_address," +
                    "oa_c_order_personal.total_fee," +
                    "oa_c_order_personal.milage_distance AS travelMileage," +
                    "oa_c_order_personal.duration_time AS travelTimeStr," +
                    "oa_c_order_personal.flight_no AS flightNo,"+
                    "oa_c_order_personal.last_push_driver_time AS lastPushDriverTime,"+
                    "date_format(oa_c_order_personal.order_time, '%Y-%m-%d %H:%i:%s' ) as order_time," +
                    "date_format(oa_c_order_personal.create_time, '%Y-%m-%d %H:%i:%s' ) as create_time," +
                    "oa_c_order_personal.cancel_reason," +
                    "oa_c_order_personal.duration_time," +
                    "oa_c_order_personal.error_status," +
                    "oa_c_order_personal.additional_fee," +
                    "oa_c_order_personal.milage_distance "+
                    "FROM " +
                    "oa_c_order_personal " +
                    "LEFT JOIN " +
                    "( SELECT " +
                        "order_no, count( 1 ) AS dayCount " +
                        "FROM oa_d_order_chartered_detail as ocd " +
                    "   GROUP BY ocd.order_no ) AS odc " +
                    "ON odc.order_no = oa_c_order_personal.order_no  " +
                    "WHERE " +
                    "oa_c_order_personal.deleted = 0  " +
                    "AND oa_c_order_personal.order_type = 7"+
                    "<if test=' dUsedId !=null and dUsedId.size() != 0'  >  " +
                    "AND  oa_c_order_personal.driver_id  IN" +
                    "<foreach collection='dUsedId' item='item'  index='index' open='(' separator=',' close=')'>" +
                    "#{item}" +
                    "</foreach>" +
                    "</if> " +
                    "<if test=' vehicleId !=null and vehicleId.size() != 0'  >    " +
                    "AND  oa_c_order_personal.vehicle_id  IN" +
                    "<foreach collection='vehicleId' item='item'  index='index' open='(' separator=',' close=')'>  " +
                    "#{item}  " +
                    "</foreach>" +
                    "</if>   " +
                    "<if test=' order_no !=null and order_no.length() != 0'  > " +
                    "AND oa_c_order_personal.order_no LIKE CONCAT('%',#{order_no},'%')" +
                    "</if> " +
                    "<if test=' order_status != null and order_status.length() != 0'  > " +
                    "<if test=' order_status == 10' > " +
                    " AND (oa_c_order_personal.order_status = #{order_status} " +
                    " OR oa_c_order_personal.order_status = 23) " +
                    "</if> " +
                    "<if test=' order_status != 10' > " +
                    " AND oa_c_order_personal.order_status = #{order_status} " +
                    "<if test='order_status == 4'>" +
                    "OR oa_c_order_personal.order_status = 6" +
                      "</if>" +
                      "</if>" +
                    "</if> " +
                    "<if test=' user_name != null and user_name.length() != 0'  >" +
                    "AND oa_c_order_personal.passenger_name LIKE CONCAT('%',#{user_name},'%')    " +
                    "</if>  " +
                    "<if test=' user_phone != null and user_phone.length() != 0'  >" +
                    "AND oa_c_order_personal.passenger_phone LIKE CONCAT('%',#{user_phone},'%')   " +
                    "</if>  " +
                    "<if test=' city_id != null and city_id.length() != 0'  >" +
                    "AND oa_c_order_personal.city_id = #{city_id}      " +
                    "</if>  " +
                    "<if test=' is_change_price != null and is_change_price.length() != 0'  >" +
                    "AND oa_c_order_personal.is_change_price = #{is_change_price}     " +
                    "</if>  " +
                    "<if test=' start_address != null and start_address.length() != 0'  >" +
                    "AND oa_c_order_personal.start_address LIKE CONCAT('%',#{start_address},'%')   " +
                    "</if>  " +
                    "<if test=' end_address != null and end_address.length() != 0'  >" +
                    "AND oa_c_order_personal.end_address LIKE CONCAT('%',#{end_address},'%')   " +
                    "</if>  " +
                    "<if test=' is_refund != null and is_refund.length() != 0'  >" +
                    "AND oa_c_order_personal.is_refund = #{is_refund}     " +
                    "</if>  " +
                    "<if test=' vehicle_type != null and vehicle_type.length() != 0'  >" +
                    "AND oa_c_order_personal.vehicle_type = #{vehicle_type}     " +
                    "</if>  " +
                    "<if test=' cancel_reason != null and cancel_reason.length() != 0'  >" +
                    "AND oa_c_order_personal.cancel_reason = #{cancel_reason}     " +
                    "</if>  " +
                    "<if test=' order_time  !=null '  >" +
                    "AND oa_c_order_personal.appointment BETWEEN  #{order_time} AND #{arrive_time}          " +
                    "</if>  " +
                    "<if test=' order_type != null and order_type.length() != 0'  >" +
                    "AND oa_c_order_personal.order_type = #{order_type}     " +
                    "</if>  " +
                    "<if test=' didi_order_id != null and didi_order_id.length() != 0'  >" +
                    "AND oa_c_order_personal.didi_order_id  LIKE CONCAT('%',#{didi_order_id},'%')      " +
                    "</if>  " +
                    "<if test=' order_channel != null and order_channel.length() != 0'  >" +
                    "AND oa_c_order_personal.order_channel = #{order_channel}     " +
                    "</if>  " +

                    "<if test=' preOfficeId != null'  >" +
                    "AND oa_c_order_personal.pre_office_id = #{preOfficeId}" +
                    "</if>  " +
                    "<if test=' personalId != null and personalId.length() != 0'  >" +
                    "AND oa_c_order_personal.personal_id = #{personalId}" +
                    "</if>  " +
                    "<if test=' office_ids != null and office_ids.size() != 0' >" +
                    "AND oa_c_order_personal.office_id in" +
                    "<foreach collection='office_ids' item='item'  index='index' open='(' separator=',' close=')'>" +
                    "#{item}   " +
                    "</foreach>   " +
                    "</if>  " +

                    "ORDER BY " +
                    "oa_c_order_personal.appointment ASC " +
                    "</script>"
    )
    List<OrderList> getCharterOrderList(
            IPage iPage,
            @Param("order_no") String orderNo,
            @Param("order_status") String orderStatus,
            @Param("user_name") String userName,
            @Param("user_phone") String userPhone,
            @Param("city_id") String cityId,
            @Param("is_change_price") String isChangePrice,
            @Param("start_address") String startAddress,
            @Param("end_address") String endAddress,
            @Param("is_refund") String isRefund,
            @Param("vehicle_type") String vehicleType,
            @Param("cancel_reason") String cancelReason,
            @Param("order_time") Date orderTime,
            @Param("arrive_time") Date arriveTime,
            @Param("order_type") String orderType,
            @Param("didi_order_id") String didiOrderId,
            @Param("order_channel") String orderChannel,
            @Param("dUsedId") List<String> dUsedId,
            @Param("vehicleId") List<String> vehicleId,
            @Param("office_ids") List<Long> offices,
            @Param("personalId") String personalId,
            @Param("preOfficeId")Long preOfficeId
    );

    /**
     * @param iPage：分页器
     * @param orderNo：订单编号
     * @param orderStatus：订单状态
     * @param userName：乘客姓名
     * @param userPhone：乘客手机号
     * @param cityId：城市Code
     * @param isChangePrice：是否改价
     * @param startAddress：出发地地址
     * @param endAddress：目的地地址
     * @param isRefund：是否退款
     * @param vehicleType：业务类型
     * @param cancelReason：取消原因
     * @param orderTime：下单时间
     * @param arriveTime：到达时间
     * @param orderType：订单类型
     * @param didiOrderId：流量方订单编号
     * @param orderChannel：订单取消
     * @param dUsedId：司机ID
     * @param vehicleId：车辆ID
     * @return
     */
    @Select(
            "<script>" +
                    "SELECT  " +
                    "oa_c_order_personal.personal_id," +
                    "oa_c_order_personal.order_no," +
                    "oa_c_order_personal.city_id," +
                    "oa_c_order_personal.vehicle_type," +
                    "oa_c_order_personal.order_type," +
                    "oa_c_order_personal.order_status," +
                    "oa_c_order_personal.passenger_name as user_name," +
                    "oa_c_order_personal.passenger_phone as user_phone," +
                    "oa_c_order_personal.didi_order_id," +
                    "oa_c_order_personal.order_channel," +
                    "oa_c_order_personal.driver_id," +
                    "oa_c_order_personal.vehicle_id," +
                    "oa_c_order_personal.vehicle_id," +
                    "oa_c_order_personal.office_id," +
                    "oa_c_order_personal.appointment," +
                    "oa_c_order_personal.start_address," +
                    "oa_c_order_personal.end_address," +
                    "oa_c_order_personal.total_fee," +
                    "oa_c_order_personal.throw_flag," +
                    "oa_c_order_personal.milage_distance AS travelMileage," +
                    "oa_c_order_personal.duration_time AS travelTimeStr," +
                    "oa_c_order_personal.flight_no AS flightNo,"+
                    "oa_c_order_personal.last_push_driver_time AS lastPushDriverTime,"+
                    "date_format(oa_c_order_personal.order_time, '%Y-%m-%d %H:%i:%s' ) as order_time," +
                    "date_format(oa_c_order_personal.create_time, '%Y-%m-%d %H:%i:%s' ) as create_time," +
                    "oa_c_order_personal.cancel_reason " +
                    "FROM " +
                    "oa_c_order_personal " +
                    "WHERE " +
                    "oa_c_order_personal.deleted = 0 AND oa_c_order_personal.order_type != 7" +
                    "<if test=' dUsedId !=null and dUsedId.size() != 0'  >  " +
                    "AND  oa_c_order_personal.driver_id  IN" +
                    "<foreach collection='dUsedId' item='item'  index='index' open='(' separator=',' close=')'>" +
                    "#{item}" +
                    "</foreach>" +
                    "</if> " +
                    "<if test=' vehicleId !=null and vehicleId.size() != 0'  >    " +
                    "AND  oa_c_order_personal.vehicle_id  IN" +
                    "<foreach collection='vehicleId' item='item'  index='index' open='(' separator=',' close=')'>  " +
                    "#{item}  " +
                    "</foreach>" +
                    "</if>   " +
                    "<if test=' order_no !=null and order_no.length() != 0'  > " +
                    "AND oa_c_order_personal.order_no LIKE CONCAT('%',#{order_no},'%')" +
                    "</if> " +
                    "<if test=' order_status != null and order_status.length() != 0'  > " +
                        "<if test=' order_status == 10' > " +
                            " AND (oa_c_order_personal.order_status = #{order_status} " +
                            " OR oa_c_order_personal.order_status = 23) " +
                        "</if> " +
                        "<if test=' order_status != 10' > " +
                            " AND oa_c_order_personal.order_status = #{order_status} " +
                        "</if> " +
                    "</if> " +
                    "<if test=' user_name != null and user_name.length() != 0'  >" +
                    "AND oa_c_order_personal.passenger_name LIKE CONCAT('%',#{user_name},'%')    " +
                    "</if>  " +
                    "<if test=' user_phone != null and user_phone.length() != 0'  >" +
                    "AND oa_c_order_personal.passenger_phone LIKE CONCAT('%',#{user_phone},'%')   " +
                    "</if>  " +
                    "<if test=' city_id != null and city_id.length() != 0'  >" +
                    "AND oa_c_order_personal.city_id = #{city_id}      " +
                    "</if>  " +
                    "<if test=' is_change_price != null and is_change_price.length() != 0'  >" +
                    "AND oa_c_order_personal.is_change_price = #{is_change_price}     " +
                    "</if>  " +
                    "<if test=' start_address != null and start_address.length() != 0'  >" +
                    "AND oa_c_order_personal.start_address LIKE CONCAT('%',#{start_address},'%')   " +
                    "</if>  " +
                    "<if test=' end_address != null and end_address.length() != 0'  >" +
                    "AND oa_c_order_personal.end_address LIKE CONCAT('%',#{end_address},'%')   " +
                    "</if>  " +
                    "<if test=' is_refund != null and is_refund.length() != 0'  >" +
                    "AND oa_c_order_personal.is_refund = #{is_refund}     " +
                    "</if>  " +
                    "<if test=' vehicle_type != null and vehicle_type.length() != 0'  >" +
                    "AND oa_c_order_personal.vehicle_type = #{vehicle_type}     " +
                    "</if>  " +
                    "<if test=' cancel_reason != null and cancel_reason.length() != 0'  >" +
                    "AND oa_c_order_personal.cancel_reason = #{cancel_reason}     " +
                    "</if>  " +
                    "<if test=' order_time  !=null '  >" +
                    "AND oa_c_order_personal.appointment BETWEEN  #{order_time} AND #{arrive_time}          " +
                    "</if>  " +
                    "<if test=' order_type != null and order_type.length() != 0'  >" +
                    "AND oa_c_order_personal.order_type = #{order_type}     " +
                    "</if>  " +
                    "<if test=' didi_order_id != null and didi_order_id.length() != 0'  >" +
                    "AND oa_c_order_personal.didi_order_id  LIKE CONCAT('%',#{didi_order_id},'%')      " +
                    "</if>  " +
                    "<if test=' order_channel != null and order_channel.length() != 0'  >" +
                    "AND oa_c_order_personal.order_channel = #{order_channel}     " +
                    "</if>  " +

                    "<if test=' preOfficeId != null'  >" +
                    "AND oa_c_order_personal.pre_office_id = #{preOfficeId}" +
                    "</if>  " +
                    "<if test=' personalId != null and personalId.length() != 0'  >" +
                    "AND oa_c_order_personal.personal_id = #{personalId}" +
                    "</if>  " +
                    "<if test=' office_ids != null and office_ids.size() != 0' >" +
                    "AND oa_c_order_personal.office_id in" +
                    "<foreach collection='office_ids' item='item'  index='index' open='(' separator=',' close=')'>" +
                    "#{item}   " +
                    "</foreach>   " +
                    "</if>  " +

                    "ORDER BY " +
                    "oa_c_order_personal.appointment ASC " +
                    "</script>"
    )
    List<OrderList> getNewOrderList(
            IPage iPage,
            @Param("order_no") String orderNo,
            @Param("order_status") String orderStatus,
            @Param("user_name") String userName,
            @Param("user_phone") String userPhone,
            @Param("city_id") String cityId,
            @Param("is_change_price") String isChangePrice,
            @Param("start_address") String startAddress,
            @Param("end_address") String endAddress,
            @Param("is_refund") String isRefund,
            @Param("vehicle_type") String vehicleType,
            @Param("cancel_reason") String cancelReason,
            @Param("order_time") Date orderTime,
            @Param("arrive_time") Date arriveTime,
            @Param("order_type") String orderType,
            @Param("didi_order_id") String didiOrderId,
            @Param("order_channel") String orderChannel,
            @Param("dUsedId") List<String> dUsedId,
            @Param("vehicleId") List<String> vehicleId,
            @Param("office_ids") List<Long> offices,
            @Param("personalId") String personalId,
            @Param("preOfficeId")Long preOfficeId
    );


    /**
     * 导出Excel文件
     *
     * @param orderNo：订单编号
     * @param orderStatus：订单状态
     * @param userName：乘客姓名
     * @param userPhone：乘客手机号
     * @param cityId：城市Code
     * @param isChangePrice：是否改价
     * @param startAddress：出发地地址
     * @param endAddress：目的地地址
     * @param isRefund：是否退款
     * @param vehicleType：业务类型
     * @param cancelReason：取消原因
     * @param orderTime：下单时间
     * @param arriveTime：到达时间
     * @param orderType：订单类型
     * @param didiOrderId：流量方订单编号
     * @param orderChannel：订单取消
     * @param dUsedId：司机ID
     * @param vehicleId：车辆ID
     * @return
     */
    @Select(
            "<script>" +
                    "SELECT  " +
                    "oa_c_order_personal.personal_id," +
                    "oa_c_order_personal.order_no," +
                    "oa_c_order_personal.city_id," +
                    "oa_c_order_personal.vehicle_type," +
                    "oa_c_order_personal.order_type," +
                    "oa_c_order_personal.order_status," +
                    "oa_c_order_personal.passenger_name as user_name," +
                    "oa_c_order_personal.passenger_phone as user_phone," +
                    "oa_c_order_personal.didi_order_id," +
                    "oa_c_order_personal.order_channel," +
                    "oa_c_order_personal.start_address," +
                    "oa_c_order_personal.end_address," +
                    "date_format(oa_c_order_personal.notarize_time, '%Y-%m-%d %H:%i:%s' ) as notarize_time," +
                    "date_format(oa_c_order_personal.meet_passenger_time, '%Y-%m-%d %H:%i:%s' ) as meet_passenger_time," +
                    "date_format(oa_c_order_personal.passenger_pay_time, '%Y-%m-%d %H:%i:%s' ) as passenger_pay_time," +
                    "date_format(oa_c_order_personal.cancel_order_time, '%Y-%m-%d %H:%i:%s' ) as cancel_order_time," +
                    "oa_c_order_personal.actual_fee," +
                    "oa_c_order_personal.total_fee," +
                    "oa_c_order_personal.start_fee," +
                    "oa_c_order_personal.duration_fee," +
                    "oa_c_order_personal.mileage_fee," +
                    "oa_c_order_personal.distance_fee," +
                    "oa_c_order_personal.driver_id," +
                    "oa_c_order_personal.vehicle_id," +
                    "date_format(oa_c_order_personal.order_time, '%Y-%m-%d %H:%i:%s' ) as order_time," +
                    "date_format(oa_c_order_personal.arrive_time, '%Y-%m-%d %H:%i:%s' ) as arrive_time,  " +
                    "date_format(oa_c_order_personal.create_time, '%Y-%m-%d %H:%i:%s' ) as create_time,  " +
                    "oa_c_order_personal.cancel_reason " +
                    "FROM " +
                    "oa_c_order_personal " +
                    "WHERE " +
                    "oa_c_order_personal.deleted = 0 " +
                    "<if test=' dUsedId !=null and dUsedId.size() != 0'  >  " +
                    "AND  oa_c_order_personal.driver_id  IN" +
                    "<foreach collection='dUsedId' item='item'  index='index' open='(' separator=',' close=')'>" +
                    "#{item}" +
                    "</foreach>" +
                    "</if> " +
                    "<if test=' vehicleId !=null and vehicleId.size() != 0'  >    " +
                    "AND  oa_c_order_personal.vehicle_id  IN" +
                    "<foreach collection='vehicleId' item='item'  index='index' open='(' separator=',' close=')'>  " +
                    "#{item}  " +
                    "</foreach>" +
                    "</if>   " +
                    "<if test='order_no != null and  order_no.length() != 0'  > " +
                    "AND oa_c_order_personal.order_no LIKE CONCAT('%',#{order_no},'%')" +
                    "</if> " +
                    "<if test='order_status != null and  order_status.length() != 0'  > " +
                    "AND oa_c_order_personal.order_status = #{order_status}" +
                    "</if> " +
                    "<if test='user_name != null and  user_name.length() != 0'  >" +
                    "AND oa_c_order_personal.passenger_name LIKE CONCAT('%',#{user_name},'%')    " +
                    "</if>  " +
                    "<if test='user_phone != null and  user_phone.length() != 0'  >" +
                    "AND oa_c_order_personal.passenger_phone LIKE CONCAT('%',#{user_phone},'%')   " +
                    "</if>  " +
                    "<if test='city_id != null and  city_id.length() != 0'  >" +
                    "AND oa_c_order_personal.city_id = #{city_id}      " +
                    "</if>  " +
                    "<if test='is_change_price != null and  is_change_price.length() != 0'  >" +
                    "AND oa_c_order_personal.is_change_price = #{is_change_price}     " +
                    "</if>  " +
                    "<if test='start_address != null and start_address.length() != 0'  >" +
                    "AND oa_c_order_personal.start_address LIKE CONCAT('%',#{start_address},'%')   " +
                    "</if>  " +
                    "<if test='end_address != null and  end_address.length() != 0'  >" +
                    "AND oa_c_order_personal.end_address LIKE CONCAT('%',#{end_address},'%')   " +
                    "</if>  " +
                    "<if test='is_refund !=null and  is_refund.length() != 0'  >" +
                    "AND oa_c_order_personal.is_refund = #{is_refund}     " +
                    "</if>  " +
                    "<if test='vehicle_type != null and  vehicle_type.length() != 0'  >" +
                    "AND oa_c_order_personal.vehicle_type = #{vehicle_type}     " +
                    "</if>  " +
                    "<if test='cancel_reason != null and  cancel_reason.length() != 0'  >" +
                    "AND oa_c_order_personal.cancel_reason = #{cancel_reason}     " +
                    "</if>  " +
                    "<if test=' order_time  !=null '  >" +
                    "AND oa_c_order_personal.create_time BETWEEN  #{order_time} AND #{arrive_time}    " +
                    "</if>  " +
                    "<if test='order_type != null and  order_type.length() != 0'  >" +
                    "AND oa_c_order_personal.order_type = #{order_type}     " +
                    "</if>  " +
                    "<if test='didi_order_id != null and  didi_order_id.length() != 0'  >" +
                    "AND oa_c_order_personal.didi_order_id  LIKE CONCAT('%',#{didi_order_id},'%')      " +
                    "</if>  " +
                    "<if test='order_channel != null and  order_channel.length() != 0'  >" +
                    "AND oa_c_order_personal.order_channel = #{order_channel}     " +
                    "</if>  " +
                    "ORDER BY " +
                    "oa_c_order_personal.create_time DESC " +
                    "</script>"
    )
    List<OrderList> getNewExportOrderExcel(
            @Param("order_no") String orderNo,
            @Param("order_status") String orderStatus,
            @Param("user_name") String userName,
            @Param("user_phone") String userPhone,
            @Param("city_id") String cityId,
            @Param("is_change_price") String isChangePrice,
            @Param("start_address") String startAddress,
            @Param("end_address") String endAddress,
            @Param("is_refund") String isRefund,
            @Param("vehicle_type") String vehicleType,
            @Param("cancel_reason") String cancelReason,
            @Param("order_time") Date orderTime,
            @Param("arrive_time") Date arriveTime,
            @Param("order_type") String orderType,
            @Param("didi_order_id") String didiOrderId,
            @Param("order_channel") String orderChannel,
            @Param("dUsedId") List<String> dUsedId,
            @Param("vehicleId") List<String> vehicleId
    );


    /**
     * @return
     */
    @Select("SELECT\n" +
            "oa_order_other_price.order_no,\n" +
            "oa_order_other_price.cost_amount \n" +
            "FROM\n" +
            "oa_order_other_price \n" +
            "WHERE\n" +
            "oa_order_other_price.order_no IN (\n" +
            "SELECT\n" +
            "oa_c_order_personal.order_no \n" +
            "FROM\n" +
            "oa_c_order_personal\n" +
            "LEFT JOIN oa_d_order ON oa_c_order_personal.order_no = oa_d_order.order_no \n" +
            "AND oa_d_order.deleted = 0\n" +
            "LEFT JOIN oa_d_user ON oa_c_order_personal.driver_id = oa_d_user.driver_id \n" +
            "AND oa_d_user.deleted = 0\n" +
            "LEFT JOIN oa_sys_vehicle ON oa_c_order_personal.vehicle_id = oa_sys_vehicle.vehicle_id \n" +
            "AND oa_sys_vehicle.deleted = 0\n" +
            "WHERE\n" +
            "oa_c_order_personal.deleted = 0 \n" +
            "ORDER BY\n" +
            "oa_c_order_personal.create_time DESC \n" +
            ")")
    List<OrderList> oaOrderOtherPrice();

    @Select("SELECT appointment,order_type,milage_distance,duration_time,start_address,end_address FROM oa_c_order_personal \n" +
            "WHERE  deleted =0 AND \n" +
            "driver_id = #{driverId} AND order_status !=10 AND order_status !=12 ORDER BY appointment DESC")
    List<OaCOrderPersonal> getDriverOrderList(@Param("driverId") String driverId);

    @Select("SELECT ocd.order_date as appointment,\n" +
            "order_type,\n" +
            "milage_distance,\n" +
            "duration_time,\n" +
            "ocd.start_address,ocd.end_address \n" +
            "FROM oa_c_order_personal as cop\n" +
            "LEFT JOIN oa_d_order_chartered_detail as ocd ON cop.order_no = ocd.order_no\n" +
            "WHERE cop.deleted = 0 AND  \n" +
            "ocd.driver_id =  #{driverId} " +
            "AND cop.order_status !=10 " +
            "AND cop.order_status !=12 " +
            "ORDER BY cop.appointment DESC")
    List<DriverOrderCard> getDriverCharterOrderList(@Param("driverId") String driverId);

    List<CmsDriverSettlementDataListRes> getParentSADataList(
                                                          @Param("officeId") String officeId,
                                                          @Param("startDate") String startDate,
                                                          @Param("endDate") String endDate,
                                                          @Param("index") Long index,
                                                          @Param("limit") Long limit);


    List<CmsDriverSettlementDataResult> getSonSADataList(@Param("driverId") Long driverId,
                                                         @Param("startDate") String startDate,
                                                         @Param("endDate") String endDate);

    Long getParentSADataListCount(@Param(("officeId")) String officeId,
                                  @Param("startDate") String startDate,
                                  @Param("endDate") String endDate);

    List<CmsDriverSettlementDataListRes> exportDriverSettlementData(@Param(("officeId")) String officeId,
                                                                    @Param("startDate") String startDate,
                                                                    @Param("endDate") String endDate);

    Double selectDriverSettlementTotalFee(@Param("driverId") Long driverId,
                                          @Param("startDate") String startDate,
                                          @Param("endDate") String endDate);

    List<CmsDriversettlementExportList> exportDriverSettlementSonData(@Param(("officeId")) String officeId,
                                                                      @Param("startDate") String startDate,
                                                                      @Param("endDate") String endDate);

    @Select("select COUNT(*) FROM oa_c_order_personal\n" +
            "\tWHERE deleted = 0\n" +
            "\tAND order_type = '7'\n" +
            "\tAND order_status = 0")
    Integer selectCharterOrderList();

    List<OaDOrder> selectDOrderList(@Param("orderNo") String orderNo);
}
